package com.example.administrator.maizuofilm.recommend.fragment;

import com.example.administrator.maizuofilm.bean.Recommend;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

/**
 * Created by Administrator on 2016/7/13.
 */
public class RecommendPresenter implements RecommendContract.RecommendPresenter {
    private RecommendContract.RecommendModel recommendModel;
    private RecommendContract.RecommendView recommendView;

    public RecommendPresenter(RecommendContract.RecommendModel recommendModel, RecommendContract.RecommendView recommendView) {
        this.recommendModel = recommendModel;
        this.recommendView = recommendView;
        EventBus.getDefault().register(this);
    }

    @Override
    public void init() {
        recommendModel.init();
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void sub(Recommend recommend) {
        if (recommend == null) {
            recommendView.onInitFail("失败");
        } else {
                recommendView.onInitSuccess(recommend);
        }
    }
}
